/**
 * Created by aixin on 2019/5/9.
 */
let measure = false;
let menuId = '';

function traverseMemu (data, path, tag = true) {
    if (tag) {
        measure = false;
        menuId = '';
    }
    for (let i = 0; i < data.length; i++) {
        if (path === data[i].menuUrl) {
            measure = true;
            menuId = data[i].id;
            break;
        }
        if (Array.isArray(data[i].children) && data[i].children.length > 0) {
            traverseMemu(data[i].children, path, false);
        }
        if (measure) {
            break;
        }
    }
}

// 获取menuId
export function getMenuId (data, path) {
    traverseMemu(data, path);
    return menuId;
}
